# Maintainer: Morten Linderud <foxboron@archlinux.org>

pkgname=podman-dnsname
_pkgname=dnsname
pkgver=1.3.1
pkgrel=2
pkgdesc="name resolution for containers"
arch=("loong64" "x86_64")
url="https://github.com/containers/dnsname"
license=("APACHE")
makedepends=("git" "go")
depends=("dnsmasq")
options=(!lto)
_commit=18822f9a4fb35d1349eb256f4cd2bfd372474d84	#refs/tags/v1.3.1^{}
source=("git+${url}.git#commit=${_commit}")
validpgpkeys=("B7DBDCA456F7335E91F1C25CD3624C551D0515C4")
sha256sums=('SKIP')

pkgver() {
    cd ${_pkgname}
    git describe --tags | sed 's/^v//;s/-/+/g'
}

build() {
  cd "${_pkgname}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export GOFLAGS="-buildmode=pie -ldflags=-linkmode=external -trimpath -mod=readonly -modcacherw"
  make
}

# check() {
#   cd "${_pkgname}"
#   go test ./...
# }

package() {
  cd "${_pkgname}"
  make PREFIX="/usr" LIBEXECDIR="/usr/lib/cni" DESTDIR="${pkgdir}" install
  install -vDm 755 "$pkgdir/usr/lib/cni/dnsname" -t "$pkgdir/opt/cni/bin/"
}
